﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using School.Entities;

namespace School.Pages.Admission
{
    public partial class GateAbsence : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            SchoolEntities db = new SchoolEntities();
            try
            {
                var n = long.Parse(TxtStudentNumber.Text);
                var student = db.TE_Student.Single(x => x.RegistrationNumber == n).Id;
                ADM_Class_Absence absence = new ADM_Class_Absence()
                {
                    Student_Id = student,
                    Date = DateTime.Now
                };

                db.AddToADM_Class_Absence(absence);
                Label2.Visible = true;
                Label1.Visible = false;
            }
            catch
            {
                Label2.Visible = true;
                Label1.Visible = false;
            }
        }
    }
}